package com.amrit.revision;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Scanner;

public class JavaIORevision {

	public static void main(String[] args) {
		JavaIORevision jv = new JavaIORevision();
		jv.readFile();
	}

	void readFile() {
		BufferedReader br;
		Scanner sc;
		BufferedWriter bwl;
		BufferedWriter bwc;
		String scline;
		try {
			br = new BufferedReader(new InputStreamReader(new DataInputStream(
					new FileInputStream("D://temp//input.txt"))), 16384);
			bwl = new BufferedWriter(
					new OutputStreamWriter(new DataOutputStream(
							new FileOutputStream("D://tempLinebyLine.txt"))), 16384);
			while ((scline = br.readLine()) != null) {
				bwl.write(scline);
				//br.readLine();
			}
			
			sc = new Scanner(new BufferedReader(new FileReader("D://temp//input.txt")));
			bwc = new BufferedWriter(
					new OutputStreamWriter(new DataOutputStream(
							new FileOutputStream("D://tempCharbyChar.txt"))), 16384);
			while (sc.hasNext()) {
				bwc.write(sc.next());
				//sc.next();
			}
		} catch (FileNotFoundException fnfe) {
			fnfe.printStackTrace();
			System.out.println("File not found");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}